/* debug_dcc.c -- serial output via the DCC port
**
** Copyright 2006, Brian Swetland.  All rights reserved.
** See provided LICENSE file or http://frotz.net/LICENSE for details.
*/

#define DCC_WRITE_FULL 2

.globl ser_init
.globl ser_putc
.globl ser_puts

ser_init:
	bx lr

ser_putc:
1:	mrc 14, 0, r1, c0, c0, 0
	tst r1, #DCC_WRITE_FULL
	bne 1b

	and r0, r0, #0xff
	mcr 14, 0, r0, c1, c0, 0
	bx lr

ser_puts:
	ldrb r1, [r0], #1
	cmp r1, #0
	bxeq lr

1:	mrc 14, 0, r2, c0, c0, 0
	tst r2, #DCC_WRITE_FULL
	bne 1b
		
	mcr 14, 0, r1, c1, c0, 0
	b ser_puts	

